package com.gxks.lhs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxks.lhs.entity.Evaluation;
import com.gxks.lhs.mapper.EvaluationMapper;
import com.gxks.lhs.service.IEvaluationService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 评价信息表 服务实现类
 * </p>
 *
 * @author LuoHaisong
 * @since 2023-05-18
 */
@Service
public class EvaluationServiceImpl extends ServiceImpl<EvaluationMapper, Evaluation> implements IEvaluationService {
    @Override
    public boolean evaluationOrder(Evaluation evaluation) {
        return save(evaluation);
    }

    @Override
    public Evaluation selectEvaluationByOrderId(Integer orderId) {
        QueryWrapper<Evaluation> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(Evaluation::getOrderId, orderId);
        return getOne(queryWrapper);
    }

    @Override
    public Page<Evaluation> selectEvaluationBySellerId(Integer sellerId, Integer current, Integer size) {
        QueryWrapper<Evaluation> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(Evaluation::getSellerId, sellerId);
        return page(new Page<>(current, size), queryWrapper);
    }
}
